
#include <stdint.h>
#include "core/api/core_api.h"

namespace {
void MessageCallback(void* service, uint32_t handle, uint32_t session, 
                     const char* data, uint16_t len) {
  char log[1024];
  sprintf(log, "session[%d] : %s", session, data);
  debug_log(log);
  return;
}
}

extern "C" void* Create(void) {
  return 0;
}

extern "C" int32_t Init(void* service, const char* param) {
  core_callback(service, MessageCallback);
  // send message to test_module
  char hello[] = "hello from test_module_2";
  char* data = new char[strlen(hello) + 1];
  strcpy(data, hello);
  CoreMessage msg;
  create_message(service, -1, true, kLogic, data, strlen(data), &msg);
  core_send_by_name("test_module", &msg);
  
  return 0;
}

extern "C" void Release(void* context) {
}

